/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package EL;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;

/**
 *
 * @author Tian
 */
@Entity
@Table(name = "Food")
@NamedQueries(
{
    @NamedQuery(name = "Foods.findAll", query = "SELECT f FROM Foods f")
})
public class Foods implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue (strategy=GenerationType.AUTO)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Column(name = "price")
    private Float price;
    @Column(name = "foodName")
    private String foodName;
    @Column(name = "isVegetarian")
    private Boolean isVegetarian;
    @Column(name = "imgPath")
    private String imgPath;
    @JoinColumn(name = "foodType", referencedColumnName = "id")
    @ManyToOne
    private FoodTypes foodTypes;
    @OneToMany(cascade = {CascadeType.MERGE,CascadeType.REFRESH,CascadeType.REMOVE}, mappedBy = "foods")
    @LazyCollection(LazyCollectionOption.FALSE)
    private List<OrderDetails> orderDetailsList;

    public Foods()
    {
    }

    public Foods(Float price, String foodName, Boolean isVegetarian, String imgPath)
    {
        this.price = price;
        this.foodName = foodName;
        this.isVegetarian = isVegetarian;
        this.imgPath = imgPath;
    }

    public Boolean getIsVegetarian()
    {
        return isVegetarian;
    }

    public void setIsVegetarian(Boolean isVegetarian)
    {
        this.isVegetarian = isVegetarian;
    }

    public Integer getId()
    {
        return id;
    }

    public void setId(Integer id)
    {
        this.id = id;
    }

    public Float getPrice()
    {
        return price;
    }

    public void setPrice(Float price)
    {
        this.price = price;
    }

    public String getImgPath()
    {
        return imgPath;
    }

    public void setImgPath(String imgPath)
    {
        this.imgPath = imgPath;
    }

    public FoodTypes getFoodTypes()
    {
        return foodTypes;
    }

    public void setFoodTypes(FoodTypes foodTypes)
    {
        this.foodTypes = foodTypes;
    }

    public List<OrderDetails> getOrderDetailsList()
    {
        return orderDetailsList;
    }

    public void setOrderDetailsList(List<OrderDetails> orderDetailsList)
    {
        this.orderDetailsList = orderDetailsList;
    }

    public String getFoodName() {
        return foodName;
    }

    public void setFoodName(String foodName) {
        this.foodName = foodName;
    }

    @Override
    public int hashCode()
    {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object)
    {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Foods))
        {
            return false;
        }
        Foods other = (Foods) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id)))
        {
            return false;
        }
        return true;
    }

    @Override
    public String toString()
    {
        return "EL.Foods[id=" + id + "]";
    }


}
